package com.wsdcd.zlg.controller;

import com.wsdcd.zlg.model.entity.User;
import com.wsdcd.zlg.model.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;

import javax.servlet.annotation.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.List;

@AllArgsConstructor
@Controller("userListServlet")
@WebServlet(name = "userListServlet", value = "/userListServlet")
public class UserListServlet extends HttpServlet {
    private final UserService userService;

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.setContentType("text/html");
        PrintWriter pw = resp.getWriter();

        List<User> list = userService.select();
        System.out.println(list);
        pw.print(list);
    }

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        doPost(req,resp);
    }
}
